package com.example.ccsystem.service;

import com.example.ccsystem.entity.Lesson;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Service;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

@Service
public class LessonServiceImpt implements LessonService{
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public String getAllLessons(){
        return jdbcTemplate.queryForObject("select count(1) from Lesson",String.class);
    }

    @Override
    public List<Map<String,Object>> findAllLesson(){
        String sql="select * from Lesson";
        List<Map<String,Object>> list=jdbcTemplate.queryForList(sql);
        return list;
    }
}
